//
//  C_NewSongCollectionViewCell.m
//  音悦咖
//
//  Created by Best on 15/7/15.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "C_NewSongCollectionViewCell.h"

@implementation C_NewSongCollectionViewCell
- (void)dealloc
{
    [_mainImageView release];
    [_titleLabel release];
    [super dealloc];
}


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self create];
    }
    return self;
}


- (void)create
{
    self.mainImageView = [[UIImageView alloc] init];
    [self addSubview:self.mainImageView];
    [_mainImageView release];
    
    
    self.titleLabel = [[UILabel alloc] init];
    [self.mainImageView addSubview:self.titleLabel];
    [_titleLabel release];
    
    
}

-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    self.mainImageView.frame = layoutAttributes.bounds;
    CGFloat width = self.mainImageView.frame.size.width;
    
    self.titleLabel.frame = CGRectMake(width - 70, 0, 60, 30);
}

- (void)setModel:(C_SonglistModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    [self.mainImageView setImageWithURL:model.pic placeholderImage:[UIImage imageNamed:@"place.jpg"]];
    self.titleLabel.text = model.title;
    
    
}

@end
